package shuzi.widget;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.shuzi.offer.R;

/**
 * @author lung 下午4:01:39 2013
 */
public class SortChoiceLayout extends LinearLayout implements OnClickListener {

	/** 价高 */
	private TextView highSort = null;
	/** 价低 */
	private TextView lowSort = null;
	/** 日期 */
	private TextView dateSort = null;
	/** 价高 的id */
	public static final int HIGH_SORT_ID = 555;
	/** 价低 的id */
	public static final int LOW_SORT_ID = HIGH_SORT_ID + 1;
	/** 日期 的id */
	public static final int DATE_SORT_ID = LOW_SORT_ID + 1;
	/**    */
	private LinearLayout.LayoutParams params = null;
	private LinearLayout.LayoutParams params1 = null;
	private LinearLayout.LayoutParams params2 = null;

	public SortChoiceLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
		initLayout(context);

	}

	public SortChoiceLayout(Context context) {
		this(context, null);
	}

	/**
	 * 初始化布局
	 */
	private void initLayout(Context context) {
		setOrientation(LinearLayout.VERTICAL);
		highSort = new TextView(context);
		lowSort = new TextView(context);
		dateSort = new TextView(context);

		highSort.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.sort));
		lowSort.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.sort));
		dateSort.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.sort));
		setBackgroundColor(Color.BLACK);
		
		params = new LinearLayout.LayoutParams(100, 50);
		params1 = new LinearLayout.LayoutParams(100, 50);
		params2 = new LinearLayout.LayoutParams(100, 50);

		setLayoutParams(new LinearLayout.LayoutParams(
				LayoutParams.WRAP_CONTENT, -2));

		highSort.setPadding(0, 0, 0, 1);
		lowSort.setPadding(0, 0, 0, 1);

		highSort.setId(HIGH_SORT_ID);
		lowSort.setId(LOW_SORT_ID);
		dateSort.setId(DATE_SORT_ID);
		
		highSort.setText("价高");
		lowSort.setText("价低");
		dateSort.setText("日期");
		
		highSort.setGravity(Gravity.CENTER);
		lowSort.setGravity(Gravity.CENTER);
		dateSort.setGravity(Gravity.CENTER);
		
		highSort.setTextColor(Color.BLACK);
		lowSort.setTextColor(Color.BLACK);
		dateSort.setTextColor(Color.BLACK);

		highSort.setOnClickListener(this);
		lowSort.setOnClickListener(this);
		dateSort.setOnClickListener(this);
		
		params1.topMargin = 1;
		params2.topMargin = 1;

		addView(highSort,params);
		addView(lowSort,params1);
		addView(dateSort,params2);

	}

	@Override
	public void onClick(View v) {
		onClickId(v.getId());
	/*	switch (v.getId()) {
		case HIGH_SORT_ID:

			break;

		case LOW_SORT_ID:

			break;

		case DATE_SORT_ID:

			break;

		default:
			break;
		}*/
	}

	public void onClickId(int id) {
		// TODO Auto-generated method stub
		
	}

}
